package cn.buk.flight.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Date;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import jakarta.persistence.Temporal;
import jakarta.persistence.TemporalType;
import jakarta.persistence.UniqueConstraint;

@Entity
@Table(name="fd_request", uniqueConstraints=@UniqueConstraint(name="uk_fd_request", columnNames={"enterprise_id", "carrier", "dport", "aport"}))
public class FdRequest {
	
	@Id
	@GeneratedValue(strategy= GenerationType.IDENTITY)
	private int id;

	@Column(name = "enterprise_id")
	private int enterpriseId;
	
	@Column(length=2)
	private String carrier;
	
	@Column(length=3, name="dport")
	private String dport;

	@Column(length=3, name="aport")
	private String aport;

	/**
	 * 查询航班价格的航班日期
	 */
	@JsonFormat(pattern = "yyyy-MM-dd",timezone="GMT+8")
	@Temporal(TemporalType.DATE)
	private Date ddate;

	/**
	 * 0-需要执行
	 * 1-已完成
	 */
	private int status;

	@Column(length = 100)
	private String remark;

	/**
	 * 尝试下载的次数
	 */
	@Column(name = "try_count")
	private Integer triesCount;

	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name="check_time")
	private Date checkTime;

	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    @Temporal(TemporalType.TIMESTAMP)
	@Column(name="lastupdate", insertable = false, updatable = false)
	private Date createTime;

	/**
	 * @return the id
	 */
	public int getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(int id) {
		this.id = id;
	}

	/**
	 * @return the carrier
	 */
	public String getCarrier() {
		return carrier;
	}

	/**
	 * @param carrier the carrier to set
	 */
	public void setCarrier(String carrier) {
		this.carrier = carrier.toUpperCase();
	}



	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public Date getCheckTime() {
		return checkTime;
	}

	public void setCheckTime(Date checkTime) {
		this.checkTime = checkTime;
	}

	public String getDport() {
		return dport;
	}

	public void setDport(String dport) {
		this.dport = dport.toUpperCase();
	}

	public String getAport() {
		return aport;
	}

	public void setAport(String aport) {
		this.aport = aport.toUpperCase();
	}

	public int getEnterpriseId() {
		return enterpriseId;
	}

	public void setEnterpriseId(int enterpriseId) {
		this.enterpriseId = enterpriseId;
	}

	public int getTriesCount() {
		if (triesCount == null) {
      return 0;
    }
		return triesCount;
	}

	public void setTriesCount(int triesCount) {
		this.triesCount = triesCount;
	}

	public Date getDdate() {
		return ddate;
	}

	public void setDdate(Date ddate) {
		this.ddate = ddate;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
}